<?
  include('../init.php');

  $aid= $_GET["aid"];
  $sql = "SELECT promo_img FROM promotion WHERE promo_id = '".$aid."'";
  $line = $db->queryUniqueObject($sql);
  
  $db->execute("DELETE FROM promotion WHERE promo_id = '$aid'");
  
  if(file_exists('../../images/promotions/'.$line->promo_img) AND $line->promo_img!=''){
    unlink('../../images/promotions/'.$line->promo_img);
    $lenght = strlen($aid);
    $thumbimg = $aid.'_thumb'.substr($line->promo_img,0,$lenght);
    @unlink('../../images/promotions/'.$thumbimg);
  }

  header("Location:index.php");
?>